/**
 * createTime: 2018/4/17 13:39
 * author: zhibin.zhao
 * description:
 */
const Koa = require('koa');
const app = new Koa();
const Router = require('koa-router');
let home = new Router();
home.get('/qishon', async(ctx)=>{
    ctx.body = "Home qishon page";
}).get('/todo', async(ctx)=>{
    ctx.body = 'Home ToDo Page';
})
let page = new Router();
page.get('/qishon', async(ctx)=>{
    ctx.body = "Page qishon page";
}).get('/todo', async(ctx)=>{
    ctx.body = 'Page ToDo Page';
})
//父级路由
let router = new Router();
router.use('/home', home.routes(), home.allowedMethods());
router.use('/page', page.routes(), page.allowedMethods());

app
    .use(router.routes())
    .use(router.allowedMethods());

app.listen(3000, ()=>{
    console.log('starting at port 3000');
});